package com.mroapp.base;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.mroapp.R;
import com.mroapp.utils.APPManager;
import com.mroapp.utils.MyDate;
import com.mroapp.utils.SharedPrefenceUtils;
import com.mroapp.utils.Var;
import com.mroapp.widget.LoadingDialog;

/**
 * Created by apple on 16/6/12.
 */
public class BaseActivity extends Activity implements View.OnClickListener {
    public LoadingDialog loadingDialog;
    public SharedPrefenceUtils spUtils;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
        loadingDialog = new LoadingDialog(this, R.style.LoadingDialog);
        spUtils=SharedPrefenceUtils.getInstance();
        spUtils.init(this);

    }

    @Override
    public void onClick(View view) {

    }
    public void showLoadingDialog(boolean isCanceledOnTouch){
        if (loadingDialog != null && !loadingDialog.isShowing()) {
            loadingDialog.setCanceledOnTouchOutside(isCanceledOnTouch);
            loadingDialog.show();
        }
    }
    public void dismissLoadingDialog(){
        if (loadingDialog != null && loadingDialog.isShowing()) {
            loadingDialog.dismiss();
        }
    }

    public static void Log_info(String log) {
        Log.i(Var.info, "-----> " + MyDate.getDateEN() + " : " + log);
    }

    public static void Log_error(String log) {
        Log.e(Var.error, "-----> " + MyDate.getDateEN() + " : " + log);
    }

    public static void Log_warn(String log) {
        Log.w(Var.warn, "-----> " + MyDate.getDateEN() + " : " + log);
    }
    protected void animLeftToRight() {
        try {
            overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
        } catch (Exception e) {
        }
    }
    /** 添加当前Activity，方便管理 */
    public static void addToActManager(Activity activity) {
        APPManager.getInstance().add(activity);
    }
    protected void animRightToLeft() {
        try {
            overridePendingTransition(R.anim.push_right_in2, R.anim.push_right_to2);
        } catch (Exception e) {
        }
    }





}
